﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Mail.Model;
using Core.Mvc.Framework;
using Core.Mvc.Framework.Action;

namespace AutoEmailSender
{
    public partial class SendByUser : UserControl,IView
    {
        public SendByUser()
        {
            InitializeComponent();
            
        }

        public ISynchronizeInvoke AsychInvoker
        {
            get { return this; }
        }

        public ActionResult BindingUsers(List<EmailUser> usrs)
        {
            comboBox1.DataSource = usrs;
            return new ActionResult() { Result="true" };
        }
        public ActionResult BindingCategories(List<EmailCategory> categories)
        {
            dataGridView1.DataSource = categories;
            return new ActionResult() { Result = "true" };
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            MvcFramwork.Call(new ActionRequest() 
            {
                Controller = "EmailController",
                Action = "GetCategoriesByUserId",
                Args = new object[] { ((EmailUser)((System.Windows.Forms.ComboBox)sender).SelectedItem).Id }
            });
        }
    }
}
